/*
 * Project : Linuxbox
 * File    : UserManAdd.java
 * Version : 1.0
 * Author  : Kevin Zhang
 *
 * Copyright (c) 2000-2001 by Linuxbox, Inc.
 * All rights reserved.
 */
package linuxbox.admin.servlet;

import javax.servlet.http.*;

import linuxbox.BoxStatic;
import linuxbox.admin.logic.*;
import linuxbox.common.*;

public class DeptManAddAction extends Action {
	protected static String successJSP = null;
	protected static String check = "CHECKED";
		
    public void doAction(HttpSession aSession, BoxSession aBoxSession, 
    HttpServletRequest req, HttpServletResponse res) throws Exception {
		BoxStatic.logger.debug("I am in DeptManAdd now ... ");
		
		String deptName = req.getParameter("DEPT_NAME");
		String address = req.getParameter("ADDRESS");			
		String phone = req.getParameter("PHONE");
		String email = req.getParameter("EMAIL");
		String note = req.getParameter("NOTE");
		String disable = req.getParameter("DISABLE");
	
		BoxStatic.logger.debug("dept name is " + deptName);
		BoxStatic.logger.debug("address is " + address);
		BoxStatic.logger.debug("phone is " + phone);
		BoxStatic.logger.debug("email is " + email);
		BoxStatic.logger.debug("note is " + note);
		BoxStatic.logger.debug("disable is " + disable);
		
		Department dept = new Department(deptName);
		dept.setAddress(address);
		dept.setPhone(phone);
		dept.setEmail(email);
		dept.setDisable(check.equals(disable));	
		dept.setNote(note);			

		UserManager um = UserManager.getInstance();
		um.addDepartment(dept);
		
		redirectFile(successJSP, req, res);
		BoxStatic.logger.debug("I am leaving DeptManAdd now ... ");
	}

	public void setSuccessJSP(String str) {
	    //"/linuxbox/jsp/admin/DeptAdmin.jsp"
		successJSP = str;
	}
}
